<template>
  <view>测试</view>
  <button @click="add">修改</button>
  <button @click="goIndex">去首页</button>
  {{ query.a }} : {{ query.b }}
  {{ testObj }}
  <view v-if="testObj.show">控制是否显示</view>
  <button @click="toggle">操作</button>
  <button @click="testRemote">测试远程</button>
</template>
<script>
  import mix from './mix.js'
  import dynamicObj from './dynamic.js'
  // 这个无效
  // import mix1 from './mix.vue'
  export default {
    mixins: [mix],
    data() {
      return {
        query: {},
        testObj: {}
      }
    },
    onLoad(options) {
      console.log(options)
      this.query = this.$route.query
    },
    methods: {
      toggle() {
        this.testObj.show = !this.testObj.show
      },
      testRemote() {
        dynamicObj.actions.forEach((res) => {
          this[res.action](res.params)
        })
      },
      goIndex() {
        this.$router.push({
          name: 'index',
          query: {
            a: 1,
            b: 2
          }
        })
      },
      onPageLeave() {
        console.log(`离开了页面`)
      },
      showOther(params) {
        console.log(params)
      }
    }
  }
</script>
